import 'package:flutter/material.dart';
import 'package:flutter_bilibili/http/core/hi_net.dart';
import 'package:flutter_bilibili/http/request/test_request.dart';
import 'package:get/get.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      theme: ThemeData(
        useMaterial3: false, // 禁用Material3样式
        primarySwatch: Colors.blue,
      ),
      home: const ContentPage(),
    );
  }
}

class ContentPage extends StatefulWidget {
  const ContentPage({super.key});

  @override
  State<ContentPage> createState() => _ContentPageState();
}

class _ContentPageState extends State<ContentPage> {
  late String content = '';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('测试请求')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () async {
                TestRequest request = TestRequest();
                request.add('id', '88888888');
                request.add('key', '88888888');
                request.add('word', '天');
                var result = await HiNet().fire(request);
                print(result);
                setState(() {
                  content = result.toString();
                });
              },
              child: const Text('发送请求'),
            ),
            SizedBox(
              height: 400,
              child: Text(content),
            ),
          ],
        ),
      ),
    );
  }
}
